define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'cdk/list/index',
        add_url: 'cdk/list/add',
        edit_url: 'cdk/list/edit',
        delete_url: 'cdk/list/delete',
        export_url: 'cdk/list/export',
        modify_url: 'cdk/list/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh','add'],
                cols: [[
                   // {type: 'checkbox'},
                    {field: 'id', title: 'ID',search: false},
                    {field: 'name', title: '名称',search: false},
                    {field: 'cdk', title: 'CDK'},
                    
                    {field: 'status', title: '状态', selectList: {0: '<a style="color:green">未使用</a>', 1: '<a style="color:red">已使用</a>'}},
                    {field: 'account', title: '账号'},
                    //{field: 'noid', title: '角色ID',search: false},
                    {field: 'gamename', title: '角色'},
                    {field: 'mintime', title: '时间范围',search: false,templet:'<div><a>{{dateFormat(d.mintime)}}</a></div>'+'<div><a>{{dateFormat(d.maxtime)}}</a></div>'},
                    
                    {field: 'addtime', title: '使用时间',search: false,templet:'<div><a>{{dateFormat(d.addtime)}}</a></div>'},
                    //{field: 'maxtime', title: '结束时间',search: false,templet:'<div><a>{{dateFormat(d.maxtime)}}</a></div>'},
                    
                    
                    
                    
                       {width: 250, title: '操作', templet: ea.table.tool},
                     
                ]],
                done: function(res, curr, count) {
                    var tableData = res.data;
                    for (var i = 0; i < tableData.length; i++) {
                        var status = tableData[i].status;
                        if (status == 1) {
                            // 隐藏操作列
                            $('.layui-table-box tbody tr:eq(' + i + ')').find('.layui-table-col-special').hide();
                        }
                    }
                }
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});